package com.summer.serialization;

import java.io.IOException;
import java.io.ObjectStreamException;
import java.io.Serializable;

public class Person implements Serializable {

	private String name;
	private int age;

	public Person(String name, int age) {
		this.name = name;
		this.age = age;
	}

	private void writeObject(java.io.ObjectOutputStream out) throws IOException {
		out.defaultWriteObject();
		System.out.println("Person writeObject.");
	}

	private void readObject(java.io.ObjectInputStream in) throws Exception {
		in.defaultReadObject();
		System.out.println("Person readObject.");
	}

	private Object writeReplace() throws ObjectStreamException {
		System.out.println("Person writeReplace.");
		return new AdapterBean(name, age);
	}
}
